package com.gykfbxxh.imovie.bean.news;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.app.utils.util.DateUtils;
import com.app.utils.util.view.image.CircleImageView;
import com.gykfbxxh.imovie.R;
import com.gykfbxxh.imovie.bean.film.FilmEntity;
import com.gykfbxxh.imovie.bean.film.FilmListEntity;
import com.gykfbxxh.imovie.utils.glide.ImageLoader;

/**
 * 列表的一张小图UI
 * Created by xuxinghai on 2017/8/30.
 */
public class ViewRightImg {

    public TextView tv_title;
    public ImageView iv_rightimg;
    public CircleImageView civ_usericon;
    public TextView tv_username;
    public TextView tv_time;
    public TextView tv_commentsum;



    private int width = 324;
    private int height = 232;

    public ViewRightImg(View convertView) {
        initView(convertView);
    }

    public ViewRightImg(View convertView, int width, int height) {
        this.width = width;
        this.height = height;
        initView(convertView);
    }

    /**
     * 初始化控件
     * @param convertView
     */
    public void initView(View convertView) {
        tv_title = (TextView) convertView.findViewById(R.id.tv_title);
        iv_rightimg = (ImageView) convertView.findViewById(R.id.iv_rightimg);
        civ_usericon = (CircleImageView) convertView.findViewById(R.id.civ_usericon);
        tv_username = (TextView) convertView.findViewById(R.id.tv_username);
        tv_time = (TextView) convertView.findViewById(R.id.tv_time);
        tv_commentsum = (TextView) convertView.findViewById(R.id.tv_commentsum);
        convertView.setTag(this);
    }

    /**
     * 加载数据
     * @param listBean
     */
    public void loadData(Context context, FilmListEntity listBean){
        FilmEntity filmEntity = listBean.getFObject();

        tv_username.setText(filmEntity.getFDirector());
        tv_title.setText(filmEntity.getFKeyword());
        tv_time.setText(DateUtils.getStrTime_mdhm(DateUtils.getTime(filmEntity.getFIntime())));
//        GlideHelper.getInstance().loadGlideImageDef(context,iv_rightimg,listBean.getFObject().getFPhotow());
//        GlideHelper.getInstance().loadGlideImage(context,civ_usericon,listBean.getFObject().getFPhotos());
        ImageLoader.getInstance().listLoadImage2Cache(context,iv_rightimg,listBean.getFObject().getFPhotow());
        ImageLoader.getInstance().loadSmallImage2Cache(context,civ_usericon,listBean.getFObject().getFPhotos());
        tv_commentsum.setText(listBean.getFObject().getFCommentct()+"");
    }

    /**
     * 加载数据
     * @param filmEntity
     */
    public void loadAboutData(Context context,FilmEntity filmEntity){
        tv_username.setText(filmEntity.getFDirector());
        tv_title.setText(filmEntity.getFKeyword());
        tv_time.setText(DateUtils.getStrTime_mdhm(DateUtils.getTime(filmEntity.getFIntime())));
//        GlideHelper.getInstance().loadLowGlideImage(context,iv_rightimg,filmEntity.getFPhotow());
//        GlideHelper.getInstance().loadGlideImage(context,civ_usericon,filmEntity.getFPhotos());
        ImageLoader.getInstance().listLoadImage2Cache(context,iv_rightimg,filmEntity.getFPhotow());
        ImageLoader.getInstance().loadSmallImage2Cache(context,civ_usericon,filmEntity.getFPhotos());
        tv_commentsum.setText(filmEntity.getFCommentct()+"");
    }

}
